package com.example.administrator.szb.adapter;
import android.support.v7.widget.RecyclerView;

/**
 * Created by pdf on 2017/8/2.
 */

public class MyOnScroll extends RecyclerView.OnScrollListener {
    private boolean isBottom = false;

    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        if(recyclerView.canScrollVertically(1)){
           isBottom = false;
        }else{
            isBottom = true;
        }
    }

    @Override
    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        if(newState == RecyclerView.SCROLL_STATE_IDLE && isBottom){//这个的RecyclerView.SCROLL_STATE_IDLEs是判断松开手指，就是到达底部且松开手指才开始加载
            scrollBottom();
        }
        isBottom = true;//这句代码很重要，因为swipeRefreshLayout 会触发onScrolled，onScrollStateChanged方法。导致判断到达底部有bug,所以要及时的将isBottom更正
    }

    public void scrollBottom() {

    }
}
